
<%@page import="ru.ifmo.rybakov.muclumon.Property"%>
<%@page import="java.util.Collection"%>
<%@page import="ru.ifmo.rybakov.muclumon.PropertyValue"%>
<%@page import="ru.ifmo.rybakov.muclumon.StringUtils"%><%@page import="ru.ifmo.rybakov.muclumon.Element"%>
<%@page import="java.util.List"%><%@ page contentType="text/html; charset=UTF-8" %>
<%
	List<Element> elements = (List<Element>) request.getAttribute("elements");
	List<Property> properties = (List<Property>) request.getAttribute("properties");
	StringBuilder sb = new StringBuilder();;
	for (Property p : properties) {
		sb.append("<option value='" + p.getName() + "'>");
		sb.append(p.getName());
		sb.append("</option>");
	}
	out.write("<table class='pv'>");
	for (Element el : elements) {
		out.write("<tr colspan='3'><b>" + el.getId() + " (" + el.getClass().getSimpleName() + ")" + (el.getName() != null ? (": " + el.getName()) : "") + "</b></tr>");
		Collection<PropertyValue> values = el.getPropertyValues();
		
		for (PropertyValue v : values) {
			out.write("<tr><td>" + v.getProperty().getName() + "</td><td>" + StringUtils.toString(v.getValue()) +"</td><td><a onclick='rp(" + el.getRevision().getId() + "," + v.getId() + ");'>remove</a></td></tr>");
		}
		
		out.write("<tr><td><select id='pl" + el.getId() + "'>" + sb.toString());
		out.write("</select><input id='pn" + el.getId() + "' /></td><td><input id='pv" + el.getId() + "'/></td><td><a onclick=\"ap(" + el.getId() + "," + el.getRevision().getId() + ");\">add</a></td></tr>");
	}
	out.write("</table>");
%>